package com.app.reptile.base;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class DataSourceFactory extends UnpooledDataSourceFactory {
	public DataSourceFactory() throws Exception {
		Properties properties = new Properties();
		String dir = System.getProperty("user.dir");
		File file = new File(dir,"config/jdbc.properties");
		if (file.exists()){
			properties.load(new FileInputStream(file));
		}else{
			properties.load(this.getClass().getResourceAsStream("/jdbc.properties"));
		}
		this.dataSource = DruidDataSourceFactory.createDataSource(properties);
//		HikariConfig config = new HikariConfig("/jdbc.properties");
//		config.setMaximumPoolSize(5);
//		this.dataSource = new HikariDataSource(config);
	}


}
